<?php

include("phpMailer_v2.1.0beta1/class.phpmailer.php");
include("phpMailer_v2.1.0beta1/class.smtp.php");
include("mailpw.php");

$from = "hubmsg@gmail.com";
$FromName = "MessageHub";

//$to = "patrick.beyeler@swisscom.com";
//$toName = "Patrick Beyeler";

$to = $_POST['email'];
$toName = $_POST['name'];

$Subject = $_POST['subject'];
$HtmlBody = $_POST['text'];


//$Subject = "This is the Subject";
//$HtmlBody = "<b>Hello World</b> <br/> This isch E-mail";
$TextBody = "Hello World!!! \n Bla Bla";

$mail=new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port 

$mail->Username   = GUSER;  // GMAIL username
$mail->Password   = GPWD;            // GMAIL password

$mail->From       = $from;
$mail->FromName   = $FromName;
$mail->Subject    = $Subject;
$mail->Body       = $HtmlBody;                      //HTML Body
$mail->AltBody    = $TextBody; //Text Body

$mail->WordWrap   = 50; // set word wrap

$mail->AddAddress($to, $toName);
$mail->AddReplyTo($from,$FromName);
//$mail->AddAttachment("/path/to/file.zip");             // attachment
//$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message has been sent";
}

?>